﻿using UnityEngine;
using System.Collections;

public class BGScaler : MonoBehaviour {

	// Use this for initialization
	void Start () {
        SpriteRenderer sp = this.gameObject.GetComponent<SpriteRenderer>();
        float width = sp.bounds.size.x;
        Debug.Log(width);
	
        float swidth = Screen.width;
        float sheight = Screen.height;
        Debug.Log(swidth+" : "+sheight);

        float sz = Camera.main.orthographicSize;

        float sc = sheight/swidth;
        Debug.Log(sc);

        float cameraHeight = sz*2;
        float cameraWidth = cameraHeight/(sc);

        float spriteScale = cameraWidth/width;
        this.transform.localScale = new Vector3(spriteScale, 1, 1);
	}
	
	// Update is called once per frame
	void Update () {
	
	}
}
